package com.zc.campus_shops.util;

import javax.servlet.http.HttpServletRequest;

import com.google.code.kaptcha.Constants;

/**
 * 验证码工具类
 * 
 * @author 请叫我小纯洁丶
 *
 */
public class CodeUtil {

	 public static boolean checkVerifyCode(HttpServletRequest request){
	        //实际的验证码
	        String verifyCodeExpected = (String) request.getSession()
	                .getAttribute( Constants.KAPTCHA_SESSION_KEY);
	        String verifyCodeActual = HttpServletRequestUtil
	                .getString( request, "verifyCodeActual" );
	 
	        System.out.println("实际验证码 ：" +verifyCodeActual);
	        if(verifyCodeActual == null || !verifyCodeExpected.equals(verifyCodeActual)){
	            return false;
	        }
	        return true;
	    }
}
